﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.fountain {
    import net.wooga.pets.loading.vos.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.fountain.*;
    import net.wooga.pets.models.world.*;

    public class StartRegenerationCommand extends Command {

        public var event:InfoEvent;
        public var world:WorldModel;
        public var symbols:SymbolModel;

        override public function execute():void{
            this.fountain.state = "in_transition";
            var _local1:RequestEvent = new RequestEvent(EventConstants.SEND_REQUEST, this.onResult);
            _local1.addRequest("start_fountain", {id:this.event.id});
            dispatch(_local1);
            dispatch(new InfoEvent(EventConstants.PLAY_EFFECT_SOUND, GameConstants.SOUND_START_FONTAIN));
        }
        private function onResult(_arg1:ResultVO):void{
            var _local2:Object;
            var _local3:ITreatable;
            var _local4:String;
            var _local5:RequestEvent;
            if (_arg1.success){
                _local2 = _arg1.data.start_fountain;
                this.symbols.symbols = _local2.symbols;
                _local3 = (this.world.getActor(this.event.id) as ITreatable);
                _local4 = ((_local3.type + "_") + WorldConstants.BABY);
                dispatch(new InfoEvent(EventConstants.PRELOAD_BABY, _local4.toLowerCase()));
                _local5 = new RequestEvent(EventConstants.SEND_REQUEST, this.onAnimationLoaded);
                _local5.addAssetRequest(ProtocolConstants.LOAD_REGENERATION, _local3.type.toLowerCase());
                dispatch(_local5);
            };
        }
        private function onAnimationLoaded(_arg1:ResultVO):void{
            this.fountain.state = WorldConstants.WORKING;
        }
        private function get fountain():IMachine{
            var _local1:IRoom = (this.world.getRoomOfActor(this.event.id) as IRoom);
            return (_local1.machine);
        }

    }
}//package net.wooga.pets.controllers.fountain 
